package com.macro.mall.bo;

public class DeadLock{
    private static final  Object o1 = new Object();
    private  static  final  Object o2 = new Object();
    public static void main(String[] arg)
    {
       Thread t1 = new Thread(()->{
           synchronized (o1)
        {
            System.out.println("t1 获得了01");
             try{
                 Thread.sleep(1000);
             }
             catch (Exception e){};
             synchronized (o2)
             {
                 System.out.println("t1获得了t2");
             }










        }
       });
        Thread t2 = new Thread(()->{
        synchronized (o2)
        {
            System.out.println("t2 获得了02");
            try{
                Thread.sleep(1000);
            }
            catch (Exception e){};
            synchronized (o1)
            {
                System.out.println("t2获得了t1");
            }

        }
       });
        t1.start();
        t2.start();
    }
}